class File
  def File.openAndProcess(*args)
    f = File.open(*args)
    yield f
    print "go on"
    f.close()
  end
  
  def File.myOpen(*args)
    aFile = File.new(*args)
    # If there's a block, pass in the file and close
    # the file when it returns
    if block_given?
      yield aFile
      aFile.close
      aFile = nil
    end
    return aFile
  end
  
end


File.openAndProcess("file.rb", "r") do |aFile|  
  print while aFile.gets  
end

File.openAndProcess("file.rb", "r") do |aFile|  
  raise "exception thrown"
end
